package com.powernode.springboot.conttroller;

import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

//ControllerAdvice+ExceptionHandler用于全局处理异常。所有的控制器都生效
@ControllerAdvice
public class GlobalExceptionHandler {
    @ExceptionHandler(value = {IllegalArgumentException.class})
    @ResponseBody
    public String handlerIllegalArgumentException(IllegalArgumentException e) {
        return "全局错误信息：" + e.getMessage();
    }
}
